package cn.qingyun.gis.modules.express.config.Exception;

import cn.hutool.core.date.DateUtil;
import cn.qingyun.gis.modules.init.system.entity.SysLog;
import cn.qingyun.gis.modules.init.system.mapper.SysLogMapper;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class CustomExceptionHandler {
    @Resource
    private SysLogMapper sysLogMapper;

    public void handleException(String message, Long start) {
        SysLog sysLog = new SysLog();
        // 创建一个异常日志对象
        long finish = System.currentTimeMillis();
        sysLog.setLogContent(message);
        sysLog.setCreateTime(DateUtil.date());
        sysLog.setLogType(3); //定时任务日志类型
        sysLog.setCreateBy("system");
        sysLog.setUserid("定时任务");
        sysLog.setCostTime(finish - start);
        sysLogMapper.insert(sysLog);
    }
}
